package org.phona.object;

import java.util.ArrayList;
import java.util.List;

public class Contact {

	String name;
	//String phoneNumber="";
	//String defaultPhoneNumber="";
	String id;
	List<Telephone> tels = new ArrayList<Telephone>();
	
	


	public Contact(String id,String name) {
		this.id=id;
		this.name=name;
	}
	

	public String getName() {
		return name;
	}
	
	

	public String getId() {
		return id;
	}

	
	public String getPrimaryPhone() {
		Integer cursor = 0;
		String result = "";
		String result2 = "";
		while(result.length()==0&&cursor<tels.size()){
			Telephone current = tels.get(cursor);
			if(current.isPrimary()){
				result=current.getPhoneNumber();
			}
			if(current.getPhoneNumber().startsWith("+336")||current.getPhoneNumber().startsWith("06")||
					current.getPhoneNumber().startsWith("+337")||current.getPhoneNumber().startsWith("07")){
				result2=current.getPhoneNumber();
			}
			cursor++;
		}
		if(result.length()==0){
			result=result2;
		}
		return result;
	}
	
	public void addPhone(String label, String type, String  phoneNumber,String primary){
		tels.add(new Telephone(label, type, phoneNumber, primary));
	}
	
	public List<Telephone> getTels() {
		return tels;
	}


	
	
}
